<?php

namespace app\admin\controller\recharge;

use app\common\controller\Backend;
use app\common\model\LevelConfig;
use app\common\model\RechargeConfig;

/**
 * 控制台
 *
 * @icon   fa fa-dashboard
 * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
 */
class Recharge extends Backend
{
    /**
     * @var \app\common\model\RechargeConfig
     */
    protected $model = null;
    protected $level = null;
    protected $configs = null;
    protected $configss = null;
    protected $noNeedRight = ['check', 'rulelist', 'selectpage', 'get_fields_list'];

    public function _initialize()
    {

        parent::_initialize();
        // $this->model = model('Config');
        $this->model = new RechargeConfig();
        $this->level = new LevelConfig();
        $this->configs = $this->model->get(1);
        $this->configss = $this->level->get(1);
        $this->view->assign("configs", $this->configs);
        $this->view->assign("configss", $this->configss);
    }

    /**
     * 查看
     */
    public function index()
    {
        if (request()->isPost()) {
            $post = request()->post('row/a');
            extract($post);
            if ($id == 0) {
                $res = $this->model->allowField(true)->save($post);
            } else {
                $res = $this->model->allowField(true)->isUpdate(true)->save($post);
            }
            return  $this->success('成功');
        }
        if (!$this->configs) {
            $this->configs = ['id' => 0, 'min_price' => 0, 'multiplejson' => ''];
        }
        $this->view->assign("configs", $this->configs);
        return $this->view->fetch();
    }
    /**
     * 编辑
     */
    public function edit_level()
    {
        if (request()->isPost()) {
            $post = request()->post('row/a');
            extract($post);
            if ($id == 0) {
                $res = $this->level->allowField(true)->save($post);
            } else {
                $res = $this->level->allowField(true)->isUpdate(true)->save($post);
            }
            return  $this->success('成功');
        }
    }
}
